$(document).ready(function(){
	s=new slider3("#Gallery");
	
	/* Binding 'click' on Top button */
	$('a.top').bind('click', function(){
		$(document.body).scrollTo($('body'),600);
	})
	
	/* Binding 'click' on Bottom button */
	$('a.bottom').bind('click', function(){
		$(document.body).scrollTo($('a[name=video]'),600);
	})
});
var slider3 = function(id){
	var self=this;
	this.div = $(id);
	this.slider3= this.div.find(".slider3");
	this.largeurCache= this.div.width();
	this.largeur=0;
	this.div.find('li').each(function(){
		self.largeur+=$(this).width();
		self.largeur+=parseInt($(this).css("padding-left"));
		self.largeur+=parseInt($(this).css("padding-right"));
		self.largeur+=parseInt($(this).css("margin-left"));
		self.largeur+=parseInt($(this).css("margin-right"));
		})
	
	this.prev= this.div.find(".prev");
	this.next= this.div.find(".next");

	this.saut= this.largeurCache/2;
	this.nbEtapes= Math.ceil(this.largeur/this.saut - this.largeurCache/this.saut);
	this.courant=0;


	
	this.next.click(function(){
	if(self.courant<=self.nbEtapes){
		self.courant++;
		self.slider3.animate({
			left:(-self.courant*self.saut)
			},1000);
		}
	
	});
	
	this.prev.click(function(){
	if(self.courant>0){
		self.courant--;
		self.slider3.animate({
			left:-self.courant*self.saut
			},1000);
		}
	
	});
	

$(function () {
		 
		for (i=1; i<=self.nbEtapes; i++){ 
			var positionTimeline = $('.anythingSlider .next').click();
		}
			$('#slider').anythingSlider({
				  onInitialized       : positionTimeline,
				
			});
		});


}

